import { Component, ComponentInterface, h } from '@stencil/core';
import * as tf from '@tensorflow/tfjs';

@Component({
  tag: 'app-root',
  styleUrl: 'app-root.css',
  shadow: true,
})
export class AppRoot implements ComponentInterface {

  componentDidLoad(): void {
    // 基本 tensor 输出
    // this.printTensor();
  }

  printTensor(): void {
    // 0 维
    const t0 = tf.tensor(0);
    t0.print();
    // 1 维
    const t1 = tf.tensor([0, 1, 2, 3, 4]);
    t1.print();
    // 2 维
    const t2 = tf.tensor([[1, 2, 3, 4], [1, 2, 3, 4]]);
    t2.print();
    // 3 维
    const t3 = tf.tensor([[[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]], [[1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4], [1, 2, 3, 4]]]);
    t3.print();
  }

  render() {
    return (
      <div>
        <header>
          <h1>Stencil App Starter</h1>
        </header>

        <main>
          <stencil-router>
            <stencil-route-switch scrollTopOffset={0}>
              <stencil-route url="/" component="app-home" exact={true} />
              <stencil-route url="/profile/:name" component="app-profile" />
            </stencil-route-switch>
          </stencil-router>
        </main>
      </div>
    );
  }
}
